package Aleehot100;

/**
 * ClassName: c05
 * Package: Aleehot100
 * Description: 接水问题
 *
 * @Author BCXJ
 * @Create 2025/5/21 16:26
 * @Version 1.0
 * @Since 1.0
 */
public class c05 {

    public static void main(String[] args) {
        int[] arr = {1,8,6,2,5,4,8,3,7};
        System.out.println(maxArea(arr));
    }

    public static int maxArea(int[] height) {
        int l = 0, r = height.length - 1;

        int num = 0, res = 0;
        while(l < r) {
            num = Math.min(height[l], height[r]);
            res = Math.max(res, (r - l) * num);
            if(num == height[l]) {
                l ++;
            }else {
                r --;
            }
        }
        return res;
    }

}
